package com.topc.api;

import com.topc.base.api.CommonResult;
import com.topc.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class FileController {

    @Autowired
    private FileService fileService;

    @RequestMapping(value = "/upload-file",method = RequestMethod.POST)
    public CommonResult<String> getUploadFile(@RequestParam("file") MultipartFile file){
        String s = fileService.uploadFile(file);
        return CommonResult.success(s);
    }

    @RequestMapping(value = "/delete-file",method = RequestMethod.POST)
    public CommonResult delUploadFile(String fileName){
        fileService.deleteFile(fileName);
        return CommonResult.success(null);
    }

}
